/// @tags: DP on Tree MUltiBackpack
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#define rint register int

using std::cin;
using std::cout;

namespace BlueQuantum {

typedef long long LL;

constexpr int maxn = 53;

struct Edge {
  int v, nxt;
} e[maxn];

int heads[maxn];

inline void add(int u, int v) {
  static int ecnt = 0;
  e[++ecnt].v = v, e[ecnt].nxt = heads[u], heads[u] = ecnt;
}

struct Node {
  LL w;
  int v, id;
  inline bool operator<(const Node& rhs) const { return v * rhs.w > rhs.v * w; }
} a[maxn];

LL f[maxn * maxn * maxn], q[maxn * maxn * maxn], num[maxn * maxn * maxn];

void dfs(int u) {
  a[u].v = 1, a[u].id = u;
  for (int i = heads[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    dfs(v);
    a[u].w += a[v].w;
    a[u].v += a[v].v;
  }
}

inline int main() {
  int n, x, d;
  cin >> n >> x >> d;
  cin >> a[1].w;
  for (int i = 2; i <= n; ++i) {
    int p;
    cin >> a[i].w >> p;
    add(p, i);
  }
  dfs(1);
  int max = n * n * n, lim = std::min(n, d);
  memset(f, 0x3f, sizeof(f));
  f[0] = 0;
  for (int i = 1; i <= n; ++i) {
    int can_use = std::min(lim, max / a[i].v);
    for (int j = 0; j < a[i].v; ++j) {
      int cnt = (max - j) / a[i].v, head = 1, tail = 0;
      for (int k = 0; k <= cnt; ++k) {
        LL pushIn = f[j + k * a[i].v] - k * a[i].w;
        while (head <= tail && pushIn <= q[tail]) tail--;
        q[++tail] = pushIn;
        num[tail] = k;
        while (head <= tail && num[head] + can_use < k) ++head;
        f[j + k * a[i].v] = std::min(f[j + k * a[i].v], q[head] + k * a[i].w);
      }
    }
  }
  std::sort(a + 1, a + n + 1);
  while (a[n].id != 1) --n;
  LL ans = 0;
  for (int i = 0; i <= max; ++i) {
    if (f[i] > x) continue;
    LL v = i, w = f[i];
    for (int j = 1; j < n; ++j) {
      LL cnt = std::min((LL)d - lim, (x - w) / a[j].w);
      v += cnt * a[j].v, w += cnt * a[j].w;
    }
    LL c = (x - w) / a[n].w;
    v += c * a[n].v, w += c * a[n].w;
    ans = std::max(ans, v);
  }
  cout << ans;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("AT4120 [ARC096D] Sweet Alchemy.in", "r", stdin);
  freopen("AT4120 [ARC096D] Sweet Alchemy.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
